<template>
  <div class="select">
    <label class="placeholder">{{ placeholder }}</label>
    <input type="text" class="input" :value="value" @input="search($event)" />
  </div>
</template>

<script>
import { debounce } from '../../utils/throttle-debounce.js'
export default {
  name: 'selectInput',
  props: ['placeholder', 'value'],
  setup(props, ctx) {
    const search = (e) => {
      debounce(() => ctx.emit('search', e.target.value))
    }


    return {
      search,
    }
  },
}
</script>

<style scope>
.select {
  position: relative;
  box-sizing: border-box;
  width: 200px;
  height: 30px;
  z-index: 9;
  background-color: #fff;
}

.input {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  padding-left: 10px;
  box-sizing: border-box;
  z-index: 3;
  background-color: transparent;
  border: 1px solid #aaa;
  border-radius: 4px;
  outline: none;
}

.placeholder {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #bbb;
  z-index: -1;
}
</style>
